package com.smartstate.dataManagement.security;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class SssClientDetailsService implements ClientDetailsService {
    @Resource
    private OauthClientDetailsService oauthClientDetailsService;
    private static volatile int num=0;

    //password,refresh_token,authorization_code,client_credentials
    @SneakyThrows
    @Override
    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
        log.info("获取客户端信息:"+num+"clientId:"+clientId);
        num++;
        ClientDetails clientDetails = oauthClientDetailsService.findOauthClientDetailsByClientId(clientId);
        return clientDetails;
    }
}
